package com.drojian.operator;

import org.junit.Test;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;

public class MergeOperator {
    @Test
    public void Test1() {
        System.out.println("======================");
        MergeOperator operator = new MergeOperator();
        operator.Test2();
        System.out.println("======================");
    }

    Observer observer = new Observer<Object>() {
        @Override
        public void onSubscribe(Disposable d) {
            System.out.println("onSubscribe:" + d);
        }

        @Override
        public void onNext(Object o) {
            System.out.println("onNext:" + o);
        }

        @Override
        public void onError(Throwable e) {
            System.out.println("onError:" + e);
        }

        @Override
        public void onComplete() {
            System.out.println("onComplete:");
        }
    };

    public void Test2() {
        //concat最多两个
        Observable.concat(
                Observable.just("aaa"), Observable.just("aaa")
        ).subscribe(observer);
        //无限个
        Observable.concatArray(
                Observable.just("aaa"), Observable.just("aaa")
        ).subscribe(observer);
    }
}
